package plus.exp;

import plus.run.Emit;
import plus.run.Label;

public class E_And extends BooleanOp {
	public E_And(Exp a, Exp b, int lineNr) { super(a,b, lineNr); }
	@Override String aThis() { return "a conjunction"; }

	@Override
	public void compilePush() {
		Label after = new Label();
		a.compileJcc(after, false);
		Emit.pop();
		b.compilePush();
		after.post();
	}
	@Override
	public void compileJcc(Label where, boolean when) {
		if (when) {
			Label after = new Label();
			a.compileJcc(after, false);
			Emit.pop();
			b.compileJcc(where, true);
			after.post();
		} else {
			a.compileJcc(where, false);
			Emit.pop();
			b.compileJcc(where, false);
		}
	}

}
